package com.neusoft.neuiotms.dcom.model.change;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "neuiot_change_plan")
@org.hibernate.annotations.Table(appliesTo = "neuiot_change_plan", comment = "变更计划表")
public class ChangePlan extends AbstractAuditModel {

    private static final long serialVersionUID = 1L;

    @Length(max = 255, message = "工作流TaskId不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NOT NULL COMMENT '工作流TaskId'")
    private String taskId;

    @Length(max = 50, message = "工单号不能超过{max}位")
    @Column(length = 50, nullable = true)
    @Comment("varchar(50) NOT NULL COMMENT '工单号'")
    private String workOrderNum;

    @Column(nullable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Comment("datetime NULL DEFAULT NULL COMMENT '计划开始时间'")
    private Date startTime;

    @Column(nullable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Comment("datetime NULL DEFAULT NULL COMMENT '计划结束时间'")
    private Date endTime;

    @Column(nullable = false)
    @Comment("bit NOT NULL COMMENT '是否中断业务（0 否 1 是）'")
    private Boolean interruptBusiness;

    @Column(nullable = false)
    @Comment("bit NOT NULL COMMENT '是否重大变更（0 否 1 是）'")
    private Boolean significantChange;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("longtext COMMENT '可能存在的风险'")
    private String risk;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("longtext COMMENT '风险处置措施'")
    private String riskManagement;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("longtext COMMENT '实施方案'")
    private String implementPlan;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("longtext COMMENT '回退方案'")
    private String fallbackPlan;

    @OneToMany(mappedBy = "changePlan", cascade = CascadeType.ALL)
    private List<ChangePlanAttachment> attachments;
}
